package studentInterface;

import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.SQLException;
import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.registerserver.dto.CourseRegisteredInfo;
import com.registerserver.dto.SubjectAndMark;
import com.registerserver.model.Course;
import com.registerserver.model.Student;
import com.registerserver.service.IService;

public class ServiceClient {
	
	public static void main(String[] args) {
		String url = "rmi://localhost:5555/RegisterCourse";
		Context ctx;
		try {
			ctx = new InitialContext();
			Object obj = ctx.lookup(url);
			IService i= (IService)obj;
			System.out.println(i.getOverAllMarkOfStudent("09095811"));
			
//			1.
			 List<CourseRegisteredInfo> course = i.getCourseRegisteredInfo("09095811");
				for (CourseRegisteredInfo courseInfo : course) {
					System.out.println("Name of Subject: "+courseInfo.getSubjectName()+" Units: "+ courseInfo.getUnits());
				}
			
//			2.
			Student student = i.getStudentInfoByID("09095811");
			System.out.println(student.getFirstName());
			System.out.println(student.getLastName());
			System.out.println(student.getHometown());
//			3.
//			int sizeOfClass = i.countStudentRegistered("","");
//			System.out.println(sizeOfClass);
//			
////			4.
//			int result = i.deleteStudying("studentID","subjectID", "courseID");
//			System.out.println(result);
//			
////			5.Delete studying
//			int result = i.deleteStudying("09023429","TBD","001");
//			System.out.println(result);
			
//			6. get bang diem cua sinh vien
			System.out.println("-------------");
			List<SubjectAndMark> list = i.getMarkOfAllSubject("09095811");
			for (SubjectAndMark subject : list) {
				System.out.println(subject.getSubjectName()+" "+subject.getMark());
			}
			
//			7. lay thong tin mon hoc de dang ki 
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}	
